package org.cuit.lmq.collection.study;

import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;

import java.util.Arrays;

/**
 * @author Seon
 * @date 2023/10/7
 */
@Slf4j
public class HashSetStructure {
    // i am build different !!!
    // 模拟一个HashMap的底层

    private static final int DEFAULT_CAPACITY = 1 << 4;
    private static final Node[] table = new Node[DEFAULT_CAPACITY];

    public HashSetStructure() {
//        table =
    }

    public static void main(String[] args) {
        // 创建Table
        System.out.println(Arrays.deepToString(table));
    }

    /**
     * 添加内部元素
     */
    public void add(String key, Object value) {

    }

    /**
     * 链接到链表末尾
     */
    private void linkTail(int index, Node node) {
        Node head = table[index];
        while (head != null && head.next != null) {
            head = head.next;
        }
        if (node == null)
            throw new RuntimeException("节点为空");
        head.next = node;
        node.next = null;
    }

    // 结点，存储数据，可以指向下一个节点，从而形成链表
    @AllArgsConstructor
    final class Node {
        Object item; // 节点内部的存放的数据
        Node next; // 下一个节点
    }

}